package com.yq.leetcodeOld.tree;

/**
 * @ClassName J27
 * @Description mirrowTree 输入二叉树，输出镜像树
 * @Author yaoqiang
 * @Date 2022/4/7 9:46
 * @Version 1.0
 */

public class J27 {
    public static void main(String[] args) {
        //TreeNode root = [4,2,7,1,3,6,9]  //出[4,7,2,9,6,3,1]
       // mirrorTree(root);
    }
    public static TreeNode mirrorTree(TreeNode root){
        //先判root不为空，递归左右节点赋值出来，再交换root.left=right
        if (root==null){return null;}
        TreeNode left=mirrorTree(root.left);
        TreeNode right=mirrorTree(root.right);
        root.left=right;
        root.right=left;
        return root;
    }


}
